package com.dmitriyp.movie.ui;

import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;

public class WidgetFactory {

	public static Text createTextField(Composite parent, String name) {
		Label label = new Label(parent, 0);
		label.setText(name);
		label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
		Text txt = new Text(parent, SWT.BORDER);
		GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
		data.minimumWidth = 200;
		txt.setLayoutData(data);
		return txt;
		
	}
	
	public static Combo createComboField(Composite parent, String name, int style) {
		Label label = new Label(parent, 0);
		label.setText(name);
		label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
		Combo combo = new Combo(parent, SWT.DROP_DOWN | style);
		GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
		data.minimumWidth = 200;
		combo.setLayoutData(data);
		return combo;
	}
	
	public static Button createButton(Composite parent, String text, int style) {
		Button btn = new Button(parent, style);
		btn.setText(text);
		return btn;
	}
	
	public static Spinner createSpinnerField(Composite parent, String name) {
		Label label = new Label(parent, 0);
		label.setText(name);
		label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
		
		Spinner spinner = new Spinner(parent, 0);
		GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
		data.minimumWidth = 200;
		spinner.setLayoutData(data);
		return spinner;
	}
}
